<template>
  <el-dialog
    :close-on-click-modal="false"
    :lock-scroll="false"
    :visible.sync="visible">
    <!--  基本信息  -->
    <el-card shadow="hover">
      <div slot="header" class="clearfix">
        <b>基本信息</b>
      </div>
      <el-row :gutter="20">
        <el-col :span="4">
          <el-image :src="dataForm.headImgUrl" style="width: 100px; height: 100px">
            <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline"></i>
            </div>
          </el-image>
        </el-col>
        <el-col :span="20">
          <el-descriptions :column="2" border>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-user"></i>
                用户名
              </template>
              {{dataForm.userName}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-male"></i>
                性别
              </template>
              <el-tag v-if="dataForm.gender === 0" size="small" type="error">未知</el-tag>
              <el-tag v-else-if="dataForm.gender === 1" size="small" type="success">男</el-tag>
              <el-tag v-else-if="dataForm.gender === 2" size="small" type="danger">女</el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-mobile-phone"></i>
                手机号
              </template>
              {{dataForm.mobile}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-sunny"></i>
                生日
              </template>
              {{dataForm.birthday}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-timer"></i>
                注册时间
              </template>
              {{dataForm.registerTime}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-map-location"></i>
                注册ip
              </template>
              {{dataForm.registerIp}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-alarm-clock"></i>
                最后登录时间
              </template>
              {{dataForm.lastLoginTime}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-map-location"></i>
                最后登录IP
              </template>
              {{dataForm.lastLoginIp}}
            </el-descriptions-item>
            <el-descriptions-item v-if="dataForm.aliUserId">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                aliUserId
              </template>
              {{dataForm.aliUserId}}
            </el-descriptions-item>
            <el-descriptions-item v-if="dataForm.openId">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                maOpenId
              </template>
              {{dataForm.openId}}
            </el-descriptions-item>
            <el-descriptions-item v-if="dataForm.mpOpenId">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                mpOpenId
              </template>
              {{dataForm.mpOpenId}}
            </el-descriptions-item>
            <el-descriptions-item v-if="dataForm.qqOpenId">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                qqOpenId
              </template>
              {{dataForm.qqOpenId}}
            </el-descriptions-item>
            <el-descriptions-item v-if="dataForm.unionId">
              <template slot="label">
                <i class="el-icon-office-building"></i>
                unionId
              </template>
              {{dataForm.unionId}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-star-off"></i>
                是否关注
              </template>
              <el-tag v-if="dataForm.subscribe === 0" size="small" type="danger">否</el-tag>
              <el-tag v-else-if="dataForm.subscribe === 1" size="small" type="success">是</el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-date"></i>
                关注时间
              </template>
              {{dataForm.subscribeTime}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-coin"></i>
                余额
              </template>
              {{dataForm.balance}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-wallet"></i>
                总积分
              </template>
              {{dataForm.integral}}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-bank-card"></i>
                会员等级
              </template>
              <el-select v-model="dataForm.userLevelId" :disabled="disabled" filterable placeholder="请选择" class="width120">
                <el-option
                  v-for="level in levelList"
                  :key="level.id"
                  :label="level.name"
                  :value="level.id">
                </el-option>
              </el-select>
              <el-button v-if="!disabled" type="primary" @click="dataFormSubmit()">确定</el-button>
            </el-descriptions-item>
          </el-descriptions>
        </el-col>
      </el-row>
    </el-card>
    <el-card shadow="hover">
      <div slot="header" class="clearfix">
        <b>账户明细</b>
      </div>
      <el-tabs tab-position="top" type="border-card" v-model="activeName">
        <el-tab-pane label="收货地址" name="first">
          <el-form :inline="true" :model="searchForm" @keyup.enter.native="getDataListAddress(1)">
            <el-form-item>
              <el-input v-model="searchForm.userName" placeholder="收货人姓名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="searchForm.mobile" placeholder="手机" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataListAddress(1)">查询</el-button>
              <el-button v-if="isAuth('mall:address:delete')" type="danger" @click="deleteHandleAddress()"
                         :disabled="dataListSelectionsAddress.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListAddress.length>0"
            :data="dataListAddress"
            border
            @selection-change="selectionChangeHandleAddress"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="userName"
              header-align="center"
              align="center"
              label="收货人姓名">
            </el-table-column>
            <el-table-column
              prop="mobile"
              header-align="center"
              align="center"
              label="手机">
            </el-table-column>
            <el-table-column
              prop="postalCode"
              header-align="center"
              align="center"
              label="邮编">
            </el-table-column>
            <el-table-column
              prop="provinceName"
              header-align="center"
              align="center"
              label="省">
            </el-table-column>
            <el-table-column
              prop="cityName"
              header-align="center"
              align="center"
              label="市">
            </el-table-column>
            <el-table-column
              prop="countyName"
              header-align="center"
              align="center"
              label="区">
            </el-table-column>
            <el-table-column
              prop="detailInfo"
              header-align="center"
              label="详细地址">
            </el-table-column>
            <el-table-column
              prop="isDefault"
              header-align="center"
              align="center"
              label="默认地址">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.isDefault === 0" size="small" type="danger">否</el-tag>
                <el-tag v-else-if="scope.row.isDefault === 1" size="small" type="success">是</el-tag>
              </template>
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleAddress"
            @current-change="currentChangeHandleAddress"
            :current-page="pageIndexAddress"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeAddress"
            :total="totalPageAddress"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="优惠券">
          <el-form :inline="true" :model="searchForm" @keyup.enter.native="getDataListCoupon(1)">
            <el-form-item>
              <el-input v-model="searchForm.couponSn" placeholder="优惠券编号" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-select v-model="searchForm.type" clearable placeholder="领取渠道" @change="getDataListCoupon(1)">
                <el-option
                  key="0"
                  label="平台发放"
                  value="0">
                </el-option>
                <el-option
                  key="1"
                  label="自动发放"
                  value="1">
                </el-option>
                <el-option
                  key="2"
                  label="领券中心"
                  value="2">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-select v-model="searchForm.status" clearable placeholder="使用状态" @change="getDataListCoupon(1)">
                <el-option
                  key="0"
                  label="未使用"
                  value="0">
                </el-option>
                <el-option
                  key="1"
                  label="已使用"
                  value="1">
                </el-option>
                <el-option
                  key="2"
                  label="已过期"
                  value="2">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataListCoupon(1)">查询</el-button>
              <el-button v-if="isAuth('mall:usercoupon:delete')" type="danger" @click="deleteHandleCoupon()"
                         :disabled="dataListSelectionsCoupon.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListCoupon.length>0"
            :data="dataListCoupon"
            border
            @selection-change="selectionChangeHandleCoupon"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="nickname"
              header-align="center"
              align="center"
              label="会员昵称">
            </el-table-column>
            <el-table-column
              prop="title"
              header-align="center"
              align="center"
              label="优惠券编号">
              <template slot-scope="scope">
                {{scope.row.title + '(' +  scope.row.couponSn + ')'}}
              </template>
            </el-table-column>
            <el-table-column
              prop="addTime"
              header-align="center"
              align="center"
              label="领用时间">
            </el-table-column>
            <el-table-column
              prop="type"
              header-align="center"
              align="center"
              label="领取类型">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.type === 0" size="small" type="success">平台发放</el-tag>
                <el-tag v-else-if="scope.row.type === 1" size="small" type="danger">自动发放</el-tag>
                <el-tag v-else-if="scope.row.type === 2" size="small" type="danger">领券中心领取</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="status"
              header-align="center"
              align="center"
              label="状态">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.status === 0" size="small" type="success">未使用</el-tag>
                <el-tag v-else-if="scope.row.status === 1" size="small" type="danger">已使用</el-tag>
                <el-tag v-else-if="scope.row.status === 2" size="small" type="info">过期</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="usedTime"
              header-align="center"
              align="center"
              label="使用时间">
            </el-table-column>
            <el-table-column
              prop="orderId"
              header-align="center"
              align="center"
              label="使用的订单编号">
              <template slot-scope="scope">
                {{scope.row.orderSn}}
              </template>
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleCoupon"
            @current-change="currentChangeHandleCoupon"
            :current-page="pageIndexCoupon"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeCoupon"
            :total="totalPageCoupon"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="收藏列表">
          <el-form>
            <el-form-item>
              <el-button v-if="isAuth('mall:collect:delete')" type="danger" @click="deleteHandleCollect()"
                         :disabled="dataListSelectionsCollect.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListCollect.length>0"
            :data="dataListCollect"
            border
            @selection-change="selectionChangeHandleCollect"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              width="200"
              prop="nickname"
              header-align="center"
              align="center"
              label="会员昵称">
            </el-table-column>
            <el-table-column
              prop="goodsName"
              header-align="center"
              align="center"
              label="商品">
            </el-table-column>
            <el-table-column
              prop="addTime"
              header-align="center"
              align="center"
              label="添加时间">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleCollect"
            @current-change="currentChangeHandleCollect"
            :current-page="pageIndexCollect"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeCollect"
            :total="totalPageCollect"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="浏览历史">
          <el-form>
          <el-form-item>
            <el-button v-if="isAuth('mall:footprint:delete')" type="danger" @click="deleteHandleFootPrint()"
                       :disabled="dataListSelectionsFootPrint.length <= 0">批量删除
            </el-button>
          </el-form-item>
        </el-form>
          <el-table
            v-if="dataListFootPrint.length>0"
            :data="dataListFootPrint"
            border
            @selection-change="selectionChangeHandleFootPrint"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              width="200"
              prop="nickname"
              header-align="center"
              align="center"
              label="会员昵称">
            </el-table-column>
            <el-table-column
              prop="goodsName"
              header-align="center"
              align="center"
              label="商品">
            </el-table-column>
            <el-table-column
              prop="addTime"
              header-align="center"
              align="center"
              label="记录时间">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleFootPrint"
            @current-change="currentChangeHandleFootPrint"
            :current-page="pageIndexFootPrint"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeFootPrint"
            :total="totalPageFootPrint"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="搜索记录">
          <el-form :inline="true" :model="searchForm" @keyup.enter.native="getDataListSearch(1)">
            <el-form-item>
              <el-select v-model="searchForm.searchFrom" clearable placeholder="搜索来源" @change="getDataListSearch(1)">
                <el-option key="1" label="微信小程序" value="1">
                </el-option>
                <el-option key="2" label="微信公众号" value="2">
                </el-option>
                <el-option key="3" label="APP" value="3">
                </el-option>
                <el-option key="4" label="H5" value="4">
                </el-option>
                <el-option key="5" label="支付宝小程序" value="5">
                </el-option>
                <el-option key="6" label="QQ小程序" value="6">
                </el-option>
                <el-option key="7" label="头条小程序" value="7">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataListSearch(1)">查询</el-button>
              <el-button v-if="isAuth('mall:searchhistory:delete')" type="danger" @click="deleteHandleSearch()"
                         :disabled="dataListSelectionsSearch.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListSearch.length>0"
            :data="dataListSearch"
            border
            @selection-change="selectionChangeHandleSearch"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="keyword"
              header-align="center"
              align="center"
              label="关键词">
            </el-table-column>
            <el-table-column
              prop="searchFrom"
              header-align="center"
              align="center"
              label="搜索来源">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.searchFrom === 1" size="small" type="success">微信小程序</el-tag>
                <el-tag v-else-if="scope.row.searchFrom === 2" size="small">微信公众号</el-tag>
                <el-tag v-else-if="scope.row.searchFrom === 3" size="small" type="info">APP</el-tag>
                <el-tag v-else-if="scope.row.searchFrom === 4" size="small" type="danger">H5</el-tag>
                <el-tag v-else-if="scope.row.searchFrom === 5" size="small" type="info">支付宝小程序</el-tag>
                <el-tag v-else-if="scope.row.searchFrom === 6" size="small" type="info">QQ小程序</el-tag>
                <el-tag v-else-if="scope.row.searchForm === 7" size="small" type="warning">头条小程序</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="addTime"
              header-align="center"
              align="center"
              label="搜索时间">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleSearch"
            @current-change="currentChangeHandleSearch"
            :current-page="pageIndexSearch"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeSearch"
            :total="totalPageSearch"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="签到">
          <el-form>
            <el-form-item>
              <el-button v-if="isAuth('mall:usersignrecord:delete')" type="danger" @click="deleteHandleSign()"
                         :disabled="dataListSelectionsSign.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListSign.length>0"
            :data="dataListSign"
            border
            @selection-change="selectionChangeHandleSign"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="signTime"
              header-align="center"
              align="center"
              label="签到时间">
            </el-table-column>
            <el-table-column
              prop="signIntegral"
              header-align="center"
              align="center"
              label="本次获得积分">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleSign"
            @current-change="currentChangeHandleSign"
            :current-page="pageIndexSign"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeSign"
            :total="totalPageSign"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="反馈">
          <el-form :inline="true" :model="searchForm" @keyup.enter.native="getDataListFeedback(1)">
            <el-form-item>
              <el-input v-model="searchForm.mobile" placeholder="手机号" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-select v-model="searchForm.status" clearable placeholder="状态" @change="getDataListFeedback(1)">
                <el-option
                  key="0"
                  label="未读"
                  value="0">
                </el-option>
                <el-option
                  key="1"
                  label="已读"
                  value="1">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-dict code="FEED_TYPE" v-model="searchForm.feedType"></el-dict>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataListFeedback(1)">查询</el-button>
              <el-button v-if="isAuth('mall:feedback:delete')" type="danger" @click="deleteHandleFeedback()"
                         :disabled="dataListSelectionsFeedback.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListFeedback.length>0"
            :data="dataListFeedback"
            border
            @selection-change="selectionChangeHandleFeedback"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="mobile"
              header-align="center"
              align="center"
              label="手机号">
            </el-table-column>
            <el-table-column
              prop="feedType"
              header-align="center"
              align="center"
              label="反馈类型">
              <template slot-scope="scope">
                <span>{{transDict('FEED_TYPE', scope.row.feedType)}}</span>
              </template>
            </el-table-column>
            <el-table-column
              show-tooltip-when-overflow
              prop="content"
              header-align="center"
              align="center"
              label="详细内容">
            </el-table-column>
            <el-table-column
              prop="status"
              header-align="center"
              align="center"
              label="状态">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.status === 0" size="small" type="danger">未读</el-tag>
                <el-tag v-else-if="scope.row.status === 1" size="small" type="success">已读</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="addTime"
              header-align="center"
              align="center"
              label="反馈时间">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleFeedback"
            @current-change="currentChangeHandleFeedback"
            :current-page="pageIndexFeedback"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeFeedback"
            :total="totalPageFeedback"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
        <el-tab-pane label="银行卡">
          <el-form :inline="true" :model="searchForm" @keyup.enter.native="getDataListBank(1)">
            <el-form-item>
              <el-input v-model="searchForm.cardName" placeholder="姓名" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="searchForm.cardNumber" placeholder="银行卡号" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-input v-model="searchForm.bankName" placeholder="银行名称" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <el-select v-model="searchForm.cardStatus" clearable placeholder="状态" @change="getDataListBank(1)">
                <el-option
                  key="2"
                  label="已解绑"
                  value="2">
                </el-option>
                <el-option
                  key="1"
                  label="已绑定"
                  value="1">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button @click="getDataListBank(1)">查询</el-button>
              <el-button v-if="isAuth('mall:userbankcard:delete')" type="danger" @click="deleteHandleBank()"
                         :disabled="dataListSelectionsBank.length <= 0">批量删除
              </el-button>
            </el-form-item>
          </el-form>
          <el-table
            v-if="dataListBank.length>0"
            :data="dataListBank"
            border
            @selection-change="selectionChangeHandleBank"
            style="width: 100%;">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              width="50">
            </el-table-column>
            <el-table-column
              prop="cardName"
              header-align="center"
              align="center"
              label="姓名">
            </el-table-column>
            <el-table-column
              prop="cardNumber"
              header-align="center"
              align="center"
              label="银行卡号">
            </el-table-column>
            <el-table-column
              prop="cardType"
              header-align="center"
              align="center"
              label="银行卡类型">
            </el-table-column>
            <el-table-column
              prop="bankName"
              header-align="center"
              align="center"
              label="银行名称">
            </el-table-column>
            <el-table-column
              prop="cardStatus"
              header-align="center"
              align="center"
              label="银行卡状态">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.cardStatus === 1" size="small" type="success">已绑定</el-tag>
                <el-tag v-else size="small" type="info">已解绑</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              prop="boundAt"
              header-align="center"
              align="center"
              label="绑定时间">
            </el-table-column>
          </el-table>
          <el-empty v-else :image-size="100" description="没有数据"></el-empty>
          <el-pagination
            @size-change="sizeChangeHandleBank"
            @current-change="currentChangeHandleBank"
            :current-page="pageIndexBank"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSizeBank"
            :total="totalPageBank"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      // 收货地址
      dataListAddress: [],
      pageIndexAddress: 1,
      pageSizeAddress: 10,
      totalPageAddress: 0,
      dataListSelectionsAddress: [],
      // 优惠券
      dataListCoupon: [],
      pageIndexCoupon: 1,
      pageSizeCoupon: 10,
      totalPageCoupon: 0,
      dataListSelectionsCoupon: [],
      // 收藏
      dataListCollect: [],
      pageIndexCollect: 1,
      pageSizeCollect: 10,
      totalPageCollect: 0,
      dataListSelectionsCollect: [],
      // 足迹
      dataListFootPrint: [],
      pageIndexFootPrint: 1,
      pageSizeFootPrint: 10,
      totalPageFootPrint: 0,
      dataListSelectionsFootPrint: [],
      // 搜索
      dataListSearch: [],
      pageIndexSearch: 1,
      pageSizeSearch: 10,
      totalPageSearch: 0,
      dataListSelectionsSearch: [],
      // 签到
      dataListSign: [],
      pageIndexSign: 1,
      pageSizeSign: 10,
      totalPageSign: 0,
      dataListSelectionsSign: [],
      // 反馈
      dataListFeedback: [],
      pageIndexFeedback: 1,
      pageSizeFeedback: 10,
      totalPageFeedback: 0,
      dataListSelectionsFeedback: [],
      // 银行卡
      dataListBank: [],
      pageIndexBank: 1,
      pageSizeBank: 10,
      totalPageBank: 0,
      dataListSelectionsBank: [],
      activeName: 'first',
      disabled: false,
      visible: false,
      searchForm: {
        userName: '',
        mobile: '',
        couponSn: '',
        type: '',
        status: '',
        cardName: '',
        cardNumber: '',
        bankName: '',
        cardStatus: ''
      },
      dataForm: {
        id: '',
        userName: '',
        password: '',
        gender: '',
        birthday: '',
        registerTime: '',
        lastLoginTime: '',
        lastLoginIp: '',
        userLevelId: '',
        nickname: '',
        mobile: '',
        registerIp: '',
        headImgUrl: '',
        aliUserId: '',
        mpOpenId: '',
        qqOpenId: '',
        openId: '',
        unionId: '',
        subscribe: '',
        subscribeTime: '',
        integral: '',
        balance: ''
      },
      levelList: []
    }
  },
  methods: {
    init (id, disabled) {
      this.disabled = disabled
      this.dataForm.id = id || ''
      this.visible = true
      this.activeName = 'first'
      this.$nextTick(() => {
        this.$http({
          url: '/mall/userlevel/queryAll',
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.levelList = data.list
          }
        })
        if (this.dataForm.id) {
          this.$http({
            url: `/mall/user/info/${this.dataForm.id}`,
            method: 'get'
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.dataForm = data.user
            }
          })
          // 收货地址
          this.getDataListAddress()
          // 优惠券
          this.getDataListCoupon()
          // 收藏
          this.getDataListCollect()
          // 足迹
          this.getDataListFootPrint()
          // 搜索
          this.getDataListSearch()
          // 签到
          this.getDataListSign()
          // 反馈
          this.getDataListFeedback()
          // 银行卡
          this.getDataListBank()
        }
      })
    },
    // 收货地址
    sizeChangeHandleAddress (val) {
      this.pageSizeAddress = val
      this.pageIndexAddress = 1
      this.getDataListAddress()
    },
    // 当前页
    currentChangeHandleAddress (val) {
      this.pageIndexAddress = val
      this.getDataListAddress()
    },
    // 多选
    selectionChangeHandleAddress (val) {
      this.dataListSelectionsAddress = val
    },
    getDataListAddress (page) {
      if (page) {
        this.pageIndexAddress = page
      }
      this.$http({
        url: '/mall/address/list',
        method: 'get',
        params: {
          'page': this.pageIndexAddress,
          'limit': this.pageSizeAddress,
          'mobile': this.searchForm.mobile,
          'userName': this.searchForm.userName,
          'userId': this.dataForm.id
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListAddress = data.page.records
          this.totalPageAddress = data.page.total
        } else {
          this.dataListAddress = []
          this.totalPageAddress = 0
        }
      })
    },
    // 删除
    deleteHandleAddress (id) {
      let ids = id ? [id] : this.dataListSelectionsAddress.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/address/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListAddress()
          }
        })
      }).catch(() => {
      })
    },
    // 每页数
    sizeChangeHandleCoupon (val) {
      this.pageSizeCoupon = val
      this.pageIndexCoupon = 1
      this.getDataListCoupon()
    },
    // 当前页
    currentChangeHandleCoupon (val) {
      this.pageIndexCoupon = val
      this.getDataListCoupon()
    },
    // 多选
    selectionChangeHandleCoupon (val) {
      this.dataListSelectionsCoupon = val
    },
    // 获取数据列表
    getDataListCoupon (page) {
      if (page) {
        this.pageIndexCoupon = page
      }
      this.$http({
        url: '/mall/usercoupon/list',
        method: 'get',
        params: {
          'page': this.pageIndexCoupon,
          'limit': this.pageSizeCoupon,
          'couponSn': this.searchForm.couponSn,
          'type': this.searchForm.type,
          'status': this.searchForm.status,
          'userId': this.dataForm.id
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListCoupon = data.page.records
          this.totalPageCoupon = data.page.total
        } else {
          this.dataListCoupon = []
          this.totalPageCoupon = 0
        }
      })
    },
    // 删除
    deleteHandleCoupon (id) {
      let ids = id ? [id] : this.dataListSelectionsCoupon.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/usercoupon/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListCoupon()
          }
        })
      }).catch(() => {
      })
    },
    // 收藏
    getDataListCollect (page) {
      if (page) {
        this.pageIndexCollect = page
      }
      this.$http({
        url: '/mall/collect/list',
        method: 'get',
        params: {
          'page': this.pageIndexCollect,
          'limit': this.pageSizeCollect,
          'userId': this.dataForm.id
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListCollect = data.page.records
          this.totalPageCollect = data.page.total
        } else {
          this.dataListCollect = []
          this.totalPageCollect = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleCollect (val) {
      this.pageSizeCollect = val
      this.pageIndexCollect = 1
      this.getDataListCollect()
    },
    // 当前页
    currentChangeHandleCollect (val) {
      this.pageIndexCollect = val
      this.getDataListCollect()
    },
    // 多选
    selectionChangeHandleCollect (val) {
      this.dataListSelectionsCollect = val
    },
    // 删除
    deleteHandleCollect (id) {
      let ids = id ? [id] : this.dataListSelectionsCollect.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/collect/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListCollect()
          }
        })
      }).catch(() => {
      })
    },
    // 获取数据列表
    getDataListFootPrint (page) {
      if (page) {
        this.pageIndexFootPrint = page
      }
      this.$http({
        url: '/mall/footprint/list',
        method: 'get',
        params: {
          'page': this.pageIndexFootPrint,
          'limit': this.pageSizeFootPrint,
          'userId': this.dataForm.id
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListFootPrint = data.page.records
          this.totalPageFootPrint = data.page.total
        } else {
          this.dataListFootPrint = []
          this.totalPageFootPrint = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleFootPrint (val) {
      this.pageSizeFootPrint = val
      this.pageIndexFootPrint = 1
      this.getDataListFootPrint()
    },
    // 当前页
    currentChangeHandleFootPrint (val) {
      this.pageIndexFootPrint = val
      this.getDataListFootPrint()
    },
    // 多选
    selectionChangeHandleFootPrint (val) {
      this.dataListSelectionsFootPrint = val
    },
    // 删除
    deleteHandleFootPrint (id) {
      let ids = id ? [id] : this.dataListSelectionsFootPrint.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/footprint/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListFootPrint()
          }
        })
      }).catch(() => {
      })
    },
    // 获取数据列表
    getDataListSearch (page) {
      if (page) {
        this.pageIndexSearch = page
      }
      this.$http({
        url: '/mall/searchhistory/list',
        method: 'get',
        params: {
          'page': this.pageIndex,
          'limit': this.pageSize,
          'userId': this.dataForm.id,
          'searchFrom': this.searchForm.searchFrom
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListSearch = data.page.records
          this.totalPageSearch = data.page.total
        } else {
          this.dataListSearch = []
          this.totalPageSearch = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleSearch (val) {
      this.pageSizeSearch = val
      this.pageIndexSearch = 1
      this.getDataListSearch()
    },
    // 当前页
    currentChangeHandleSearch (val) {
      this.pageIndexSearch = val
      this.getDataListSearch()
    },
    // 多选
    selectionChangeHandleSearch (val) {
      this.dataListSelectionsSearch = val
    },
    // 删除
    deleteHandleSearch (id) {
      let ids = id ? [id] : this.dataListSelectionsSearch.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/searchhistory/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListSearch()
          }
        })
      }).catch(() => {
      })
    },
    // 获取数据列表
    getDataListSign (page) {
      if (page) {
        this.pageIndexSign = page
      }
      this.$http({
        url: '/mall/usersignrecord/list',
        method: 'get',
        params: {
          'page': this.pageIndex,
          'limit': this.pageSize,
          'userId': this.dataForm.id
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListSign = data.page.records
          this.totalPageSign = data.page.total
        } else {
          this.dataListSign = []
          this.totalPageSign = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleSign (val) {
      this.pageSizeSign = val
      this.pageIndexSign = 1
      this.getDataListSign()
    },
    // 当前页
    currentChangeHandleSign (val) {
      this.pageIndexSign = val
      this.getDataListSign()
    },
    // 多选
    selectionChangeHandleSign (val) {
      this.dataListSelectionsSign = val
    },
    // 删除
    deleteHandleSign (id) {
      let ids = id ? [id] : this.dataListSelectionsSign.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/usersignrecord/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListSign()
          }
        })
      }).catch(() => {
      })
    },
    getDataListFeedback (page) {
      if (page) {
        this.pageIndexFeedback = page
      }
      this.$http({
        url: '/mall/feedback/list',
        method: 'get',
        params: {
          'page': this.pageIndexFeedback,
          'limit': this.pageSizeFeedback,
          'userId': this.dataForm.id,
          'mobile': this.searchForm.mobile,
          'status': this.searchForm.status,
          'feedType': this.searchForm.feedType
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListFeedback = data.page.records
          this.totalPageFeedback = data.page.total
        } else {
          this.dataListFeedback = []
          this.totalPageFeedback = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleFeedback (val) {
      this.pageSizeFeedback = val
      this.pageIndexFeedback = 1
      this.getDataListFeedback()
    },
    // 当前页
    currentChangeHandleFeedback (val) {
      this.pageIndexFeedback = val
      this.getDataListFeedback()
    },
    // 多选
    selectionChangeHandleFeedback (val) {
      this.dataListSelectionsFeedback = val
    },
    // 删除
    deleteHandleFeedback (id) {
      let ids = id ? [id] : this.dataListSelectionsFeedback.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/feedback/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListFeedback()
          }
        })
      }).catch(() => {
      })
    },
    // 银行卡
    getDataListBank (page) {
      if (page) {
        this.pageIndexBank = page
      }
      this.$http({
        url: '/mall/userbankcard/list',
        method: 'get',
        params: {
          'page': this.pageIndexBank,
          'limit': this.pageSizeBank,
          'userId': this.dataForm.id,
          'cardName': this.searchForm.cardName,
          'cardNumber': this.searchForm.cardNumber,
          'bankName': this.searchForm.bankName,
          'cardStatus': this.searchForm.cardStatus
        }
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataListBank = data.page.records
          this.totalPageBank = data.page.total
        } else {
          this.dataListBank = []
          this.totalPageBank = 0
        }
      })
    },
    // 每页数
    sizeChangeHandleBank (val) {
      this.pageSizeBank = val
      this.pageIndexBank = 1
      this.getDataListBank()
    },
    // 当前页
    currentChangeHandleBank (val) {
      this.pageIndexBank = val
      this.getDataListBank()
    },
    // 多选
    selectionChangeHandleBank (val) {
      this.dataListSelectionsBank = val
    },
    // 删除
    deleteHandleBank (id) {
      let ids = id ? [id] : this.dataListSelectionsBank.map(item => {
        return item.id
      })
      this.$confirm('确定对所选项进行[删除]操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: '/mall/userbankcard/delete',
          method: 'post',
          data: ids
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500
            })
            this.getDataListBank()
          }
        })
      }).catch(() => {
      })
    },
    // 表单提交
    dataFormSubmit () {
      this.$http({
        url: `/mall/user/${!this.dataForm.id ? 'save' : 'update'}`,
        method: 'post',
        data: this.dataForm
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.$message({
            message: '操作成功',
            type: 'success',
            duration: 1500
          })
          this.visible = false
          this.$emit('refreshDataList')
        }
      })
    }
  }
}
</script>
